document.getElementById("createxiti").onclick=function(){
	window.open ("create_xiti.html?type=POST", "_blank", "height=800, width=1300, top=160, left=200, toolbar=no, menubar=no, scrollbars=yes, resizable=no, location=no, status=no");
	
}
function delxiti(e){
	var id=e.getAttribute("sid")
	jQuery.ajax({
		"url":"/ti/",
		"error":errorAjax,
		"beforeSend":start_load_pic,
		"complete":stop_load_pic,
		"type":"DELETE",
		"data":{"id":id},
		"success":function(data){
			data=JSON.parse(data)
			if(!data.status){
				showErrorInfo(data.content)
				return false;
			}
			showSuccessNotic()
			$(e).parent().parent().remove()
		}
		
	})
}
function getList(){
	$.ajax({
		"url":"/ti/",
		"error":errorAjax,
		"beforeSend":start_load_pic,
		"complete":stop_load_pic,
		"dataType":"jsonp",
		"success":function(data){
			if(!data.status){
				showErrorInfo(data.content)
				return false;
			}
			var tab=document.getElementById("tab")	
			var data=data.content;
			for(var i=0;i<data.length;i++){
				var tr=document.createElement("tr")

				var td=document.createElement("td")
				td.textContent=data[i].class_name;
				tr.appendChild(td)
			
				var td=document.createElement("td")
				td.textContent=data[i].name;
				td.style.cssText="text-overflow: ellipsis ;max-width:400px;white-space: nowrap;overflow: hidden"
				tr.appendChild(td)
			
				var td=document.createElement("td")
				td.textContent=data[i].value;
				tr.appendChild(td)
			
				var td=document.createElement("td")
				td.textContent=data[i].date;
				tr.appendChild(td)
			
				var td=document.createElement("td")
				var eBtn=document.createElement("btn")
				eBtn.setAttribute("data",JSON.stringify(data[i]))
				eBtn.onclick=function(){
					var data=this.getAttribute("data")
					window.open ("create_xiti.html?type=PUT&data="+data, "_blank", "height=800, width=1300, top=160, left=200, toolbar=no, menubar=no, scrollbars=yes, resizable=no, location=no, status=no");
				}
				eBtn.className="btn btn-primary btn-xs"
				eBtn.textContent="编辑"
				// td.appendChild(eBtn)   去除编辑功能

				var vBtn=document.createElement("a")
				
				vBtn.setAttribute("href","cheungssh.html?page=view_student_xiti_status.html&class_number="+data[i].class_number+"&data="+JSON.stringify(data[i])+"&ti_id="+data[i].id)
				vBtn.style.cssText="margin-left:4px"
				vBtn.className="btn btn-success btn-sm"
				vBtn.textContent="查看完成情况"
				td.appendChild(vBtn)
				tr.appendChild(td)

				var dBtn=document.createElement("btn")
				dBtn.style.cssText="margin-left:4px"
				dBtn.setAttribute("sid",data[i].id)
				dBtn.onclick=function(){
					if(confirm("真的要删除吗？")===false){
						return false;
					}
					delxiti(this)
				}
				dBtn.className="btn btn-danger btn-sm"
				dBtn.textContent="删除"
				td.appendChild(dBtn)
				tr.appendChild(td)




				tab.appendChild(tr)
			
			}
		
		}
	})
}
getList()
